package shuanfa.tree;

//判断0-n 质数个数
public class Eratosthenes {
    public static int eratosthenes(int n){
        boolean[] isPrime = new boolean[n];//false代表是质数
        int count = 0;
        for (int i = 2; i < n; i++) {
            if (!isPrime[i]){
                count++;
                for (int j = i*i; j < n; j=j+n) {
                    isPrime[j] = true;
                }
            }
        }
        return count;
    }
}
